#include "CdiBox.h"
#include "CdiRenderObjectList.h"

CdiBox::CdiBox( LPDIRECT3DDEVICE9 pDevice, float scale ) 
: CdiRenderBase( pDevice ),
  m_simpleVertex( NULL ),
  m_scale( scale )
{
  Setup();
}

CdiBox::CdiBox() 
: CdiRenderBase( NULL ),
  m_simpleVertex( NULL ),
  m_scale( -1 )
{
  Setup();
}

CdiBox::~CdiBox(void)
{
  if( m_simpleVertex )
  {
    delete[] m_simpleVertex;
  }
  m_simpleVertex = NULL;
}

void CdiBox::Setup()
{
  m_simpleVertex = new ColorVertex[8];
  float scale = m_scale;
  if( m_scale = -1 ) 
    scale = 1;
  
  // Front
  /* 0 */m_simpleVertex[0] = ColorVertex( -1.0f * scale, 1.0f * scale, -1.0f * scale,/* 0, 1, */ D3DCOLOR_XRGB( 40, 10, 10 ));
  /* 1 */m_simpleVertex[1] = ColorVertex( -1.0f * scale, -1.0f * scale, -1.0f * scale,/* 0, 1, */D3DCOLOR_XRGB( 10, 40, 40 ));
  /* 2 */m_simpleVertex[2] = ColorVertex( 1.0f * scale, -1.0f * scale, -1.0f * scale,/* 0, 1, */D3DCOLOR_XRGB( 10, 60, 50 ));
  /* 3 */m_simpleVertex[3] = ColorVertex( 1.0f * scale, 1.0f * scale, -1.0f * scale,/* 0, 1, */D3DCOLOR_XRGB( 90, 10, 10 ));

  // Backside
  /* 4 */m_simpleVertex[4] = ColorVertex( -1.0f * scale, 1.0f * scale, 1.0f * scale,/* 0, 1, */D3DCOLOR_XRGB( 40, 60, 10 ));
  /* 5 */m_simpleVertex[5] = ColorVertex( -1.0f * scale, -1.0f * scale, 1.0f * scale,/* 0, 1, */D3DCOLOR_XRGB( 10, 20, 60 ));
  /* 6 */m_simpleVertex[6] = ColorVertex( 1.0f * scale, -1.0f * scale, 1.0f * scale,/* 0, 1, */D3DCOLOR_XRGB( 70, 60, 10 ));
  /* 7 */m_simpleVertex[7] = ColorVertex( 1.0f * scale, 1.0f * scale, 1.0f * scale,/* 0, 1, */D3DCOLOR_XRGB( 10, 40, 20 ));
}

void CdiBox::SetScale( float scale )
{
  m_scale = scale;
}
